import config from '@/config'
import RequestBase from '@/utils/request.js'

const request = new RequestBase(config.specialWorkUrl)
const baseRequest = new RequestBase(config.baseUrl)

/**
 * @description 作业项目列表
 */
export function queryWorkProject(params) {
  return request.get('/spw/work-project/info/list', params)
}
/**
 * @description 作业项目列表
 */
export function queryImportWorkProjectList(params) {
  return request.get('/spw/work-project/list', params)
}

/**
 * @description 取消作业项目
 */
export function projectCancel(projectInfoId) {
  return request.put(`/spw/work-project/cancel/${projectInfoId}`)
}

/**
 * 审批项目
 */
export function changeAuditUser(projectId, userId, staffName) {
  return request.put(`/spw/work-project/changeAuditUser/${projectId}/${userId}/${staffName}`)
}

/**
 * @description 获取作业项目类型
 */
export function queryWorkProjectType() {
  return request.get('/spw/work-project/type/list')
}

/**
 * 审核作业项目
 */
export function approve(projectId, status) {
  return request.put(`/spw/work-project/review/${projectId}/${status}`)
}

/**
 * 获取作业项目列表详情
 */
export function getWorkProjectListDetail(projectInfoId) {
  return request.get(`/spw/work-project/getListDetail/${projectInfoId}`)
}

/**
 * 添加作业项目
 */
export function createWorkProject(data) {
  return request.post('/spw/work-project/saveInfo', data)
}

/**
 * 编辑作业项目
 */
export function updateWorkProject(data) {
  return request.put('/spw/work-project', data)
}

/**
 * 获取作业项目详情
 */
export function getWorkProjectDetail(query) {
  return request.get('/spw/work-project/info', query)
}

/**
 * 完结作业项目
 */
export function finishWorkProject(data) {
  return request.put('/spw/work-project/complete', data)
}

/**
 * 获取待办数量
 */
export function getSpecialWorkCount() {
  return request.get('/mobile/spw/ticket/task/count')
}

/**
 * 获取特殊作业待办列表
 */
export function getSpecialWorkTodo(query) {
  return request.get('/spw/ticket-review/todo', query)
}

// 转办作业票
export function turnTicket(data) {
  return request.post('/spw/ticket-review/turn', data)
}

// 围栏校验
export function poiValid(ticketId) {
  return request.post(`/spw/ticket-review/positionCheck/${ticketId}`)
}

// 作业项目审批待办数量
export function approveNum(params) {
  return request.get('/mobile/spw/project/review/todo-count', params)
}

// 作业项目审批列表
export function getApproveList(params) {
  return request.get('/mobile/spw/project/review/list', params)
}

// 作业项目信息
export function getProjectInfo(projectInfoId) {
  return request.get(`/mobile/spw/project/info/${projectInfoId}`)
}

// 作业项目类型
export function getWorkType(projectInfoId) {
  return request.get(`/mobile/spw/project/ticket/list/${projectInfoId}`)
}

// 作业项目审批
export function projectApprove(projectInfoId, status, p3) {
  return request.put(`/mobile/spw/project/review/${projectInfoId}/${status}`)
}

// 作业项目更换审批人
export function projectApprovalChange(projectId, staffUserId, staffUserName) {
  return request.put(`/mobile/spw/project/changeAuditUser/${projectId}/${staffUserId}/${staffUserName}`)
}
/**
 * @description 获取特殊作业下作业类型
 */
export function getSpecialWorkType() {
  return baseRequest.get('/activiti/biz-config/sub-category/SPECIAL_WORK')
}
/**
 * @description 获取区域
 */
export function getFactoryArea() {
  return baseRequest.get('/basic-info/info/web/factory-area/getSimpleTree')
}

/**
 * @description 获取区域
 */
export function addProjectWork(data) {
  return request.post('/spw/work-project/save-work', data)
}

/**
 * 获取项目监护人
 */
export function queryProjectGuardian(params) {
  return baseRequest.get(`/basic-info/info/web/staff/getByQualification/page/19`, {
    ...params,
    staffName: params.keyword ?? ''
  })
}
